package com.qinghong.scheduling.Controller;

import com.qinghong.scheduling.model.RespBean;
import com.qinghong.scheduling.model.SysJob;
import com.qinghong.scheduling.service.SysJobService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/jobs")
public class SysJobController {

    @Autowired
    SysJobService sysJobService;

    @GetMapping("/")
    public List<SysJob> getAllJobs() {
        return sysJobService.getAllJobs();
    }

    @PutMapping("/")
    public RespBean updateSysJob(@RequestBody SysJob sysJob){
        Boolean result = sysJobService.updateSysJob(sysJob);
        if (result){
            return RespBean.ok("更新作业成功");
        }
        return RespBean.error("更新作业失败");
    }
}
